package mx.com.theboard.login;


import mx.com.theboard.TheboardApplication;
import mx.com.theboard.menu.Menu;

import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.LoginForm.LoginEvent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.LoginForm;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

@SuppressWarnings("serial")
public class LoginWindow extends Window {

   

    public LoginWindow() {

        super("Login");
        super.center();
        
        setHeight("195px");
        setWidth("230px");
        setClosable(false);
        setScrollable(false);
        
        // Add some content; a label and a close-button
        final LoginForm login = new LoginForm();
        login.addListener(new LoginForm.LoginListener() {
			
			public void onLogin(LoginEvent event) {
				if(event.getLoginParameter("username").equals("123") &&event.getLoginParameter("password").equals("123")){
					login.getApplication().getMainWindow().removeAllComponents();
					
					Menu menu = new Menu();
					HorizontalLayout hl = new HorizontalLayout();
					hl.setStyleName("tbmenu");
					hl.setWidth("100%");
					hl.setHeight("50px");		
					hl.addComponent(menu);
					login.getApplication().getMainWindow().addComponent(hl);
					
					login.getApplication().getMainWindow().removeWindow(TheboardApplication.registro);
					login.getApplication().getMainWindow().removeWindow(login.getWindow());
				}
			
			}
		});
           
                
        
        
        login.setWidth("100%");
        login.setHeight("100px");
        login.setStyleName("tblogin");
        
        login.setUsernameCaption("Usuario");
        login.setPasswordCaption("Password");
        login.setLoginButtonCaption("Entrar");
        
       this.addComponent(login);
          

    }

}
